<?php

	   $shop_result = mysql_query("select * from ".$table_Prefix."term where belong = 'shop' and interm = 'root' and publish = 1 order by CONVERT(name using gbk) asc ");


	   ?>
<div id="shop_list"></div>

  <script>
  layui.use('tree', function(){
    var tree = layui.tree;
   
   	
  //渲染
    var inst1 = tree.render({
      elem: '#shop_list'  //绑定元素
      ,showCheckbox:true
	  ,id:'shop_list'
	  ,data: [
	  	
		<?php 
					   $i = 0;
					   while ($shop = mysql_fetch_array($shop_result)) { //一级
					   		if($i > 0){echo ',';}
					   ?>
					   {title: '<?php echo $shop['name']?>'
					   ,id: <?php echo $shop['nid']?>
    				   ,field: ''
                       <?
						if (compare_term($shop['nid'], $shop_term_nid)) {
					   ?>
						,checked:true
						,spread:true
						<?php
						}
						
					   		$i ++;
					   	$shop2_result = mysql_query("select * from ".$table_Prefix."term where belong = 'shop' and interm = 'term1' and publish = 1 and term1 =  ".$shop['nid']);
							if($shop2_result){
						?>
								,children: [
						<?php	
								$ii = 0;
								while ($shop2 = mysql_fetch_array($shop2_result)) { //二级
									if($ii > 0){echo ',';}
						?>
								{title: '<?php echo $shop2['name']?>'
							     ,id: <?php echo $shop2['nid']?>
							     ,field: ''
								 <?
								if (compare_term($shop2['nid'], $shop_term_nid)) {
							   ?>
								,checked:true
								,spread:true
								<?php
								}
								 $ii++;
								$shop3_result = mysql_query("select * from ".$table_Prefix."term where belong = 'shop' and interm = 'term2' and publish = 1 and term2 =  ".$shop2['nid']);
                    	    	
									if($shop3_result){
						?>
										,children: [
						<?php
										$iii = 0;
										while ($shop3 = mysql_fetch_array($shop3_result)) { //三级
											
											if($iii > 0){echo ',';}
						?>
                        					{title: '<?php echo $shop3['name']?>'
											,id: <?php echo $shop3['nid']?>
											,field: ''
											<?
											if (compare_term($shop3['nid'], $shop_term_nid)) {
											?>
											,checked:true
											,spread:true
											<?php
											}
											?>
											}
                        <?php		
											
											$iii++;
										}
						?>
										
										]
									}
						<?php
									}
								}
						?>
								]}
						<?php
						    }
					   }
					   ?>
        
		]
    });
	
  });
  
  
  </script>

       